﻿using AutoMapper;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Portal.Model;
using Rhino.Mocks;

namespace Portal.Repository.Tests.Units.AutoMapper
{
	[TestClass]
	public class UserInterfaceToUserEntityTests : BaseTests
	{
		protected override void InitializeTest()
		{
		
		}

		[TestMethod]
		public void UserInterface_Update_UserEntity()
		{
			var user = Mocks.DynamicMock<IUser>();
			user.Expect(x => x.Login).Return("login");
			user.Expect(x => x.Id).Return(123);
			user.LastName = "last name";
			user.FirstName = "first name";

			var entity = new User()
			{
				Login = "login",
				FirstName = "entity first name",
				LastName = "entity last name"
			};

			Mocks.ReplayAll();

			user.MapUpdate(entity);

			Assert.AreEqual(user.LastName, entity.LastName);
			Assert.AreEqual(user.FirstName, entity.FirstName);
			Assert.AreEqual(user.Login, entity.Login);
			Assert.AreNotEqual(user.Id, entity.Id);
		}
	}
}
